


(function($) {

	"use strict";

	$(window).stellar({
    responsive: true,
    parallaxBackgrounds: true,
    parallaxElements: true,
    horizontalScrolling: false,
    hideDistantElements: false,
    scrollProperty: 'scroll'
  });


	var fullHeight = function() {

		$('.js-fullheight').css('height', $(window).height());
		$(window).resize(function(){
			$('.js-fullheight').css('height', $(window).height());
		});

	};
	fullHeight();

	// loader
	var loader = function() {
		setTimeout(function() { 
			if($('#ftco-loader').length > 0) {
				$('#ftco-loader').removeClass('show');
			}
		}, 1);
	};
	loader();

  var carousel = function() {
		$('.home-slider').owlCarousel({
	    loop:true,
	    autoplay: true,
	    margin:0,
	    animateOut: 'fadeOut',
	    animateIn: 'fadeIn',
	    nav:true,
	    dots: true,
	    autoplayHoverPause: false,
	    items: 1,
	    navText : ["<span class='ion-ios-arrow-back'></span>","<span class='ion-ios-arrow-forward'></span>"],
	    responsive:{
	      0:{
	        items:1
	      },
	      600:{
	        items:1
	      },
	      1000:{
	        items:1
	      }
	    }
		});

		$('.carousel-testimony').owlCarousel({
			center: true,
			loop: true,
			items:1,
			margin: 30,
			stagePadding: 0,
			nav: false,
			navText: ['<span class="ion-ios-arrow-back">', '<span class="ion-ios-arrow-forward">'],
			responsive:{
				0:{
					items: 1
				},
				600:{
					items: 2
				},
				1000:{
					items: 3
				}
			}
		});

	};
	carousel();

	$('nav .dropdown').hover(function(){
		var $this = $(this);
		// 	 timer;
		// clearTimeout(timer);
		$this.addClass('show');
		$this.find('> a').attr('aria-expanded', true);
		// $this.find('.dropdown-menu').addClass('animated-fast fadeInUp show');
		$this.find('.dropdown-menu').addClass('show');
	}, function(){
		var $this = $(this);
			// timer;
		// timer = setTimeout(function(){
			$this.removeClass('show');
			$this.find('> a').attr('aria-expanded', false);
			// $this.find('.dropdown-menu').removeClass('animated-fast fadeInUp show');
			$this.find('.dropdown-menu').removeClass('show');
		// }, 100);
	});


	$('#dropdown04').on('show.bs.dropdown', function () {
	  console.log('show');
	});

	// magnific popup
	$('.image-popup').magnificPopup({
    type: 'image',
    closeOnContentClick: true,
    closeBtnInside: false,
    fixedContentPos: true,
    mainClass: 'mfp-no-margins mfp-with-zoom', // class to remove default margin from left and right side
     gallery: {
      enabled: true,
      navigateByImgClick: true,
      preload: [0,1] // Will preload 0 - before current, and 1 after the current image
    },
    image: {
      verticalFit: true
    },
    zoom: {
      enabled: true,
      duration: 300 // don't foget to change the duration also in CSS
    }
  });

  $('.popup-youtube, .popup-vimeo, .popup-gmaps').magnificPopup({
    disableOn: 700,
    type: 'iframe',
    mainClass: 'mfp-fade',
    removalDelay: 160,
    preloader: false,

    fixedContentPos: false
  });


  var counter = function() {
		
		$('#section-counter').waypoint( function( direction ) {

			if( direction === 'down' && !$(this.element).hasClass('ftco-animated') ) {

				var comma_separator_number_step = $.animateNumber.numberStepFactories.separator(',')
				$('.number').each(function(){
					var $this = $(this),
						num = $this.data('number');
						console.log(num);
					$this.animateNumber(
					  {
					    number: num,
					    numberStep: comma_separator_number_step
					  }, 7000
					);
				});
				
			}

		} , { offset: '95%' } );

	}
	counter();

	var contentWayPoint = function() {
		var i = 0;
		$('.ftco-animate').waypoint( function( direction ) {

			if( direction === 'down' && !$(this.element).hasClass('ftco-animated') ) {
				
				i++;

				$(this.element).addClass('item-animate');
				setTimeout(function(){

					$('body .ftco-animate.item-animate').each(function(k){
						var el = $(this);
						setTimeout( function () {
							var effect = el.data('animate-effect');
							if ( effect === 'fadeIn') {
								el.addClass('fadeIn ftco-animated');
							} else if ( effect === 'fadeInLeft') {
								el.addClass('fadeInLeft ftco-animated');
							} else if ( effect === 'fadeInRight') {
								el.addClass('fadeInRight ftco-animated');
							} else {
								el.addClass('fadeInUp ftco-animated');
							}
							el.removeClass('item-animate');
						},  k * 50, 'easeInOutExpo' );
					});
					
				}, 100);
				
			}

		} , { offset: '95%' } );
	};
	contentWayPoint();

	// container left ul li事件
	$("#kuaixun_left li").bind("click", function() {
		
		$("#kuaixun_left li").removeClass("active1");
		$(this).addClass("active1");
		
		$("#content_right0").removeClass("active");
		$("#content_right1").removeClass("active");
		$("#content_right2").removeClass("active");
		$("#content_right3").removeClass("active");
		$("#content_right4").removeClass("active");
		// 唯一一个显示
		$("#content_right"+$(this).index()).addClass("active");
		//alert("abc"+$(this).index());
		
		
		
		//$("#kuaixun_left li").css({color:'#1ba12d', fontWeight:'normal'});
		//$("#kuaixun_left li").css("font-weight", "none");
		//$(this).css({color:'blue',fontWeight:'bold', zIndex:5});
		//$(this).css("font-weight","bold");
	});

	
	

// 显示地图
    var map = new AMap.Map('container', {
        resizeEnable: true, //是否监控地图容器尺寸变化
        zoom:4, //初始化地图层级
        center: [116.397428, 39.90923] //初始化地图中心点
		//mapStyle:"amap://styles/graffiti"
    });
      //var styleName = "amap://styles/graffiti";
      //map.setMapStyle(styleName);



// 限制地图使用范围
      var bounds = map.getBounds();
      map.setLimitBounds(bounds);

      for(var i=0;i<capitals.length;i+=1){
        var center = capitals[i].center;
        var circleMarker = new AMap.CircleMarker({
          center:center,
          radius:10+Math.random()*10,//3D视图下，CircleMarker半径不要超过64px
          strokeColor:'white',
          strokeWeight:2,
          strokeOpacity:0.5,
          fillColor:'rgba(0,0,255,1)',
          fillOpacity:0.5,
          zIndex:10,
          bubble:true,
          cursor:'pointer',
          clickable: true
        })
        circleMarker.setMap(map)
      }

			

})(jQuery);

function setSta_value(thiSta_cls, avgthiList1, avgthiList2, avgthiRates) {
	
	(function($) {

		"use strict";
		
		
		
		var colorList = ['#FFC367', '#a3bb63', '#DA9CFF', '#27727B',
        '#5D84FF', '#C1232B', '#B5C334', '#FCCE10', '#E87C25',
        '#FE8463', '#9BCA63', '#FAD860', '#F3A43B', '#60C0DD',
        '#D7504B', '#C6E579', '#F4E001', '#F0805A', '#26C0C0'];
		
		
		// 首页的统计图
		var option = {
			tooltip: {
				trigger: 'axis',
				axisPointer: {
					type: 'cross',
					crossStyle: {
						color: '#3398DB'
					}
				},
				formatter: function (params, ticket, callback) {
					//console.log("111---"+params);
					var showHtm="";
					for(var i=0;i<params.length;i++){
						
						//名称
						var name = params[i].seriesName;
						//值
						var value = params[i].value;
						if(i!=2) {
							showHtm+= name + '：' + value+'<br>'
						}else {
							showHtm+= name + '：' + value+'%'
						}
					}
					return showHtm;
				} // 这里是鼠标移上去的显示数据
			},
			color:colorList,
			toolbox: {
				feature: {
					dataView: {show: true, readOnly: false},
					magicType: {show: true, type: ['line', 'bar']},
					restore: {show: true},
					saveAsImage: {show: true}
				}
			},
			legend: {
				data: thiSta_cls
			},
			xAxis: [
				{
					type: 'category',
					data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
					axisPointer: {
						type: 'shadow'
					}
				}
			],
			yAxis: [
				{
					type: 'value',
					name: 'TOP100景区THI均值',
					min: 0,
					max: 70,
					interval: 10,
					axisLabel: {
						formatter: '{value}'
					}
				},
				{
					type: 'value',
					name: '同比',
					min: -100,
					max: 40,
					interval: 30,
					axisLabel: {
						formatter: '{value} %'
					}
				}
			],
			series: [
				{
					name: '2019年',
					type: 'bar',
					barWidth:'25%',
					data: avgthiList1
				},
				{
					name: '2020年',
					type: 'bar',
					barWidth:'25%',
					data: avgthiList2
				},
				{
					name: '同比',
					type: 'line',
					yAxisIndex: 1,
					data: avgthiRates,
					label: {
			            normal: {
			                show: true,
			                position: 'outside',
			                formatter: '{c}%' // 这里是数据展示的时候显示的数据
			            }
			        }

				}
			]
		};
	var myChart = echarts.init(document.getElementById('chart1'));
	// 使用刚指定的配置项和数据显示图表。
	myChart.setOption(option);


	})(jQuery);
}
